package com.cheers.dao.impl;

import com.cheers.dao.UserDao;
import com.cheers.model.User;

public class UserDaoImpl extends AbstractDaoImpl implements UserDao {

	@Override
	public User getUserByUsernamePassword(String username, String password)
			throws Exception {
		User result = null;
		String sql = "from User where username=? and password=?";
		Object[] params = new Object[] {username, password};
		result = findByHql(User.class, sql, params);
		return result;
	}
	
	@Override
	public boolean hasUserByUsername(String username) throws Exception {
		String sql = "from User where username=?";
		Object[] params = new Object[] {username};
		User user = findByHql(User.class, sql, params);
		if (user != null) {
			return true;
		}
		return false;
	}

}
